package com.jams.goodox.activity.login;

import android.content.Intent;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.KeyEvent;

import com.jams.goodox.BaseActivity;
import com.jams.goodox.R;
import com.jams.goodox.SePref;
import com.jams.goodox.TownApplicationLike;
import com.jams.goodox.activity.home.HomeActivity;
import com.jams.goodox.utils.DelayUtils;
import com.jams.goodox.utils.StatusBarCompat;


/**
 * 引动页
 * Created by DWCloud on 2016/5/16.
 */
public class LaunchActivity extends BaseActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.launch_activity;
    }

    @Override
    protected void init() {
        setTitleVisibility(false);
        StatusBarCompat.compat(this, ContextCompat.getColor(this, R.color.main_theme));//沉侵式头部
//        TinkerUtils.getTinkerMessage(this);
        DelayUtils.doAfterDelay(1500, new DelayUtils.DelayDoListener() {
            @Override
            public void doAction() {
                startActivityManager();
            }
        });
        //startActivityManager();
    }

    /**
     * 启动页面管理器
     * 如果是初次打开app，进入广告图页面。非->
     * 如果未登录（token为空）进入登录页。已登录->
     * 如果是企业账号登录，进入企业账户首页，个人账户进入个人账户首页
     */
    private void startActivityManager() {
        if (TownApplicationLike.getInstance() == null) return;
//        if (!"1".equals(SePref.getGuide())) {
//            SePref.setGuide("1");
//            startActivity(new Intent(this,GuideActivity.class));
//            finish();
//            return;
//        }
        //未登录进入登录页
//        if (TextUtils.isEmpty(SePref.getToken())) {
//            startActivity(new Intent(this, LoginActivity.class));
//            finish();
//            return;
//        }
        startActivity(new Intent(this, HomeActivity.class));
        finish();
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // 在欢迎界面屏蔽BACK键
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return false;
        }
        return false;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
